<template>
  <div class="money1">
    <el-card class="cardOut2">
      <!--      <div slot="header">-->
      <!--        <div class="headerTitleClass">工资列表</div>-->
      <!--      </div>-->

      <div>
        <el-table
            :data="videoList"
            border
            style="width: 100%">
          <el-table-column
              prop="username"
              label="申请人姓名">
          </el-table-column>
          <el-table-column
              prop="id"
              label="员工编号">
          </el-table-column>
          <el-table-column
              prop="basicsalary"
              label="申请基本薪资">
          </el-table-column>
          <el-table-column
              prop="jiangjin"
              label="申请奖金">
          </el-table-column>
          <el-table-column
              prop="baoxiao"
              label="申请报销">
          </el-table-column>
<!--          <el-table-column-->
<!--              prop="status"-->
<!--              label="是否处理">-->
<!--          </el-table-column>-->
          <el-table-column
              label="处理状态">
            <template slot-scope="scope">
              <el-tag :type="scope.row.status1 === 0?'warning':scope.row.status1 === 1?'success':'danger'">{{scope.row.status1 === 0?'未处理':scope.row.status1 === 1?'已同意':'已拒绝'}}</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                  size="mini"
                  type="primary"
                  @click="handleEdit(scope.row)">同意申请</el-button>
              <el-button
                  size="mini"
                  type="danger"
                  @click="handleDelete( scope.row)">拒绝申请</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="fenye">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[5, 8, 12,15]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "money1",
  data(){
    /* 定义初始化变量 */
    return{
    videoList:[],
      pageNum:1,
      pageSize:5,
      total: 0
    }
  },
  /* 定义事件函数 */
  methods:{
    handleEdit(tongyi){
      this.$axios.put('/admin/updateSalary3/'+tongyi.id).then(res=>{
        if(res.data.code ===200){
          this.$message.success("同意成功")
          this.queryDatabase()
        }else{
          this.$message.error("同意失败")
        }
      })
    },
    handleSizeChange(val){
      this.pageSize=val
      this.queryDatabase()
    },
    handleCurrentChange(val){
      this.pageNum=val
      this.queryDatabase()
    },

    handleDelete(jujue1){
    this.$axios.delete('/admin/jujube/'+jujue1.id).then(res=>{
      if(res.data.code===200){
        this.$message.success("拒绝申请成功")
        this.queryDatabase()
      }else{
        this.$message.error("拒绝失败")
      }
    })
    },
    queryDatabase(){
     this.$axios.get('/admin/queryDatabase1',{params:{
        pageNum:this.pageNum,
         pageSize:this.pageSize,
         // username:this.username
       }}).then(res=>{
       console.log(res.data.data)
      this.videoList=res.data.data.rows
       this.total=res.data.data.total
    })
    }
  },
  /* vue的生命周期函数
     当页面加载完毕就会执行created里面的函数
  */
  created() {
    this.queryDatabase();
  }
}
</script>

<!-- scoped此属性可以防止当前页面的样式不会影响其他页面样式 -->
<style scoped>
@import url("Money1.css");
</style>